<?
if(!defined ('U_MOD'))
{
	echo"<meta http-equiv='refresh' content='0;url=/index.php'>";
	exit;
}

$metaArray=array();

$metaQuery=mysql_query("SELECT * FROM ".$PortalPref."metatags");

while($metaResult=mysql_fetch_assoc($metaQuery))
{
	$metaArray[$metaResult['metatags_title']]= pEcho($metaResult['metatags_content']);
}

$titlesQuery=mysql_query("SELECT * FROM  ".$PortalPref."titles WHERE titles_mkey='".$CURRENT_MODULE."'");
if (mysql_num_rows($titlesQuery)==1)
{
	$titlesResult=mysql_fetch_assoc($titlesQuery);
	if ($titlesResult['titles_mask']=='' || is_null($titlesResult['titles_mask']))
	{
		$PAGE_TITLE=$portal_title;
	}else
	{
		$titleP=$portal_title; $titleD=date('d.m.y', $portal_time); $titleT=date('H:i:s', $portal_time);
		$posM = strpos($titlesResult['titles_mask'], '[M]');
		if ($posM !== false)
		{
			$titleModulesQuery=mysql_query("SELECT modules_".$module_type."_name AS mname FROM ".$PortalPref."modules WHERE modules_key='".$CURRENT_MODULE."'");
    		$titleModulesResult=mysql_fetch_assoc($titleModulesQuery);
			$titleM=pEcho($titleModulesResult['mname']);
		}else
			 $titleM='';

		$posG = strpos($titlesResult['titles_mask'], '[G]');
		if ($posG === false)
		{
			$titleG='';
			$TitleFile=false;
		}
		else
		{
			$TitleFile=false;
			if (file_exists('mod/'.$CURRENT_MODULE.'/title.php'))
			{
				$TitleFile=true;
				include 'mod/'.$CURRENT_MODULE.'/title.php';
				$titleG=$GtitleGenerator;
			}else
				$titleG='';
		}


		$searchArray=array('[P]', '[M]', '[D]', '[T]', '[G]');
		$replaceArray=array($titleP ,$titleM, $titleD, $titleT, $titleG);
		$PAGE_TITLE=str_replace($searchArray, $replaceArray, $titlesResult['titles_mask']);
	}

    if ($titlesResult['titles_key_generate']==1)
    {
    	if ($TitleFile)
    		$PAGE_KEYWORDS=$KeywordsGenrator;
    	else
    	{
    		if (file_exists('mod/'.$CURRENT_MODULE.'/title.php'))
    		{
    			include 'mod/'.$CURRENT_MODULE.'/title.php';
    			$PAGE_KEYWORDS=$KeywordsGenrator;
    		}else
    			$PAGE_KEYWORDS=$metaArray['_META_PORTAL_KEYWORDS_'];
    	}
    }else
    {
    	if ($titlesResult['titles_keywords']=='' || is_null($titlesResult['titles_keywords']))
    		$PAGE_KEYWORDS=$metaArray['_META_PORTAL_KEYWORDS_'];
	    else
    		$PAGE_KEYWORDS=pEcho($titlesResult['titles_keywords']);
    }
}else
{
	$PAGE_TITLE=$portal_title;
	$PAGE_KEYWORDS=$metaArray['_META_PORTAL_KEYWORDS_'];
}


?>